package xushuo.dao.service.tools.weixin;

import org.apache.log4j.Logger;
import xushuo.dao.entity.weixin.menu.*;

import java.io.IOException;

/**
 * Create by zhangpe0312@qq.com on 2018/2/1.
 */
public class MenuManager {

    private static Logger logger = Logger.getLogger(MenuManager.class);

    public static void main(String[] args) throws IOException {

//            // 调用接口创建菜单
//            int result = .createMenu(getMenu(), AccessToken.getAccess_token());
//
//            // 判断菜单创建结果
//            if (0 == result)
//                logger.info("菜单创建成功！");
//            else
//                logger.info("菜单创建失败，错误码：" + result);

    }

    /**
     * 组装菜单数据
     * 初步模拟菜单
     * @return
     */
    private static Menu getMenu() {
        ViewButton btn11 = new ViewButton();
        btn11.setName("我要应聘");
        btn11.setUrl("http://sem.youlanw.com/zp_pdetail/382015.html?utm_source=baidu&utm_term=%E6%97%AD%E7%A1%95%E6%8B%9B%E8%81%98");

        ClickButton btn12 = new ClickButton();
        btn12.setName("旭硕");
        btn12.setKey("12");

        ClickButton btn13 = new ClickButton();
        btn13.setName("人工服务");
        btn13.setKey("13");


        ClickButton btn21 = new ClickButton();
        btn21.setName("员工颁奖");
        btn21.setKey("21");

        ClickButton btn22 = new ClickButton();
        btn22.setName("组团旅游");
        btn22.setKey("22");

        ClickButton btn23 = new ClickButton();
        btn23.setName("新年尾牙活动");
        btn23.setKey("23");


        ClickButton btn31 = new ClickButton();
        btn31.setName("就职机会");
        btn31.setKey("31");

        ClickButton btn32 = new ClickButton();
        btn32.setName("旭硕发展");
        btn32.setKey("32");

        ClickButton btn33 = new ClickButton();
        btn33.setName("旭硕简介");
        btn33.setKey("33");


        /**
         * 微信：  mainBtn1,mainBtn2,mainBtn3底部的三个一级菜单。
         */

        ComplexButton mainBtn1 = new ComplexButton();
        mainBtn1.setName("客服中心");
        //一级下有4个子菜单
        mainBtn1.setSub_button(new Button[] {btn11, btn12, btn13 });


        ComplexButton mainBtn2 = new ComplexButton();
        mainBtn2.setName("旭硕文化");
        mainBtn2.setSub_button(new ClickButton[] { btn21, btn22, btn23});


        ComplexButton mainBtn3 = new ComplexButton();
        mainBtn3.setName("旭硕机会");
        mainBtn3.setSub_button(new ClickButton[] { btn31, btn32, btn33 });


        /**
         * 封装整个菜单
         */
        Menu menu = new Menu();
        menu.setButton(new Button[] { mainBtn1, mainBtn2, mainBtn3 });

        return menu;
    }

}
